import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const Home = () => import('../views/Home')
const ChildOne = () => import('../views/ChildOne')
const ChildC = () => import('../views/ChildC')

const routes = [
  {
    path:'/',
    component:Home
  },
  {
    // path:'/childOne/:id',
    path:'/childOne/:id',
    name:'ChildOne',
    component:ChildOne,
    beforeEnter:(to,from,next)=>{
      console.log('beforeEnter')
      next()
    },
    meta:{
      isActive:true
    },
    children:[
      {
        path:'',
        component:ChildC
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

// router.beforeEach((to,from,next)=>{
//   console.log('beforeEach')
//   next()
// })
// router.beforeResolve((to,from,next)=>{
//   console.log('beforeResolve')
//   next()
// })
// router.afterEach(()=>{
//   console.log('afterEach')
// })

export default router
